package io.lvdaxian.mybatis10.builder;


import io.lvdaxian.mybatis10.session.Configuration;
import io.lvdaxian.mybatis10.type.TypeAliasRegistry;
import io.lvdaxian.mybatis10.type.TypeHandlerRegistry;

/**
 * 构建器的基类，建造者模式
 *
 * @author lihh
 */
public class BaseBuilder {
  protected final Configuration configuration;
  protected final TypeAliasRegistry typeAliasRegistry;
  protected final TypeHandlerRegistry typeHandlerRegistry;
  
  public BaseBuilder(Configuration configuration) {
    this.configuration = configuration;
    
    this.typeAliasRegistry = configuration.getTypeAliasRegistry();
    this.typeHandlerRegistry = configuration.getTypeHandlerRegistry();
  }
  
  public Configuration getConfiguration() {
    return configuration;
  }
  
  /**
   * 这里可以根据alias别名 解析出Class
   *
   * @param alias 别名
   * @return 返回 Class 字节实例
   * @author lihh
   */
  protected Class<?> resolveAlias(String alias) {
    return typeAliasRegistry.resolveAlias(alias);
  }
}
